<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
	

<h:head>
	<title>祖龙娱乐  - BI系统</title>
	<link href="../../css/component.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/highcharts.js"></script>
	<script type="text/javascript" src="../../js/drawChart.js"></script>
</h:head>

<h:body>
	<ui:param name="bean" value="#{platformAndChannelRealTimeAction}" />
	
	<span class="pagetitle">实时数据 —— 分渠道概况</span>
	<p:separator />
	
	<!-- 右侧页面顶部查询部分 -->
	<h:form id="fsearch">
		<p:poll interval="20" listener="#{bean.search()}" update=":dform" />
	
		<p:growl id="growl" showDetail="true" sticky="true" />
		<h:outputLabel value="查看日期：" />
        <p:calendar value="#{bean.lookDate}" mode="popup" pattern="yyyy-MM-dd" />
        <h:outputLabel value="（只能查看最近7天的数据）" />
		&#160;&#160;&#160;
		
        <p:commandButton value="查询" action="#{bean.search()}" update=":data" ajax="false" />
         <br />
		<h:outputLabel style="font-size:10px" value="数据更新频率为1分钟 ，#{bean.lastUpdateTimeStr}，下表实时数据为0点截止更新时间点内数据汇总" />
	</h:form>
	<br />

	<!-- 数据展示部分，包含表格和图表 -->
	<h:form id="dform">
		<div class="data" id="data">
			<p:panel id="panel" header="整体数据" style="margin-bottom:10px;">
				<p:dataTable id="dlist" var="l" value="#{bean.platformDatas}" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="15,30" rows="15" style="text-align:center;">
                    <p:column headerText="平台名称" styleClass="column grcnewUser" sortBy="#{pageHelper.getPlatformNameById(l.platformid)}">
						<h:outputLabel value="#{pageHelper.getPlatformNameById(l.platformid)}" />
					</p:column>
                    <p:column headerText="激活设备" styleClass="column grcnewUser" sortBy="#{l.activate}">
                        <h:outputLabel value="#{l.activate}" />
                    </p:column>
                    <p:column headerText="新增设备" styleClass="column grcnewUser" sortBy="#{l.newDevice}">
                        <h:outputLabel value="#{l.newDevice}" />
                    </p:column>
					<p:column headerText="新增帐号" styleClass="column grcnewUser" sortBy="#{l.newUser}">
						<h:outputLabel value="#{l.newUser}" />
					</p:column>
					<p:column headerText="活跃帐号" styleClass="column grcnewUser" sortBy="#{l.activeUser}">
						<h:outputLabel value="#{l.activeUser}" />
					</p:column>
					<p:column headerText="付费帐号" styleClass="column grcnewUser" sortBy="#{l.payUser}">
						<h:outputLabel value="#{l.payUser}" />
					</p:column>
					<p:column headerText="付费金额#{pageHelper.getMoneyType()}" styleClass="column grcnewUser" sortBy="#{l.pay}">
						<h:outputLabel value="#{l.pay}" />
					</p:column>
					<p:column headerText="活跃付费率" styleClass="column grcnewUser" sortBy="#{l.payUserInActiveRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.payUserInActiveRadio)}" />
					</p:column>
					<p:column headerText="付费ARPU#{pageHelper.getMoneyType()}" styleClass="column grcnewUser" sortBy="#{l.payARPU}">
						<h:outputLabel value="#{l.payARPU}" />
					</p:column>
					<p:column headerText="活跃ARPU#{pageHelper.getMoneyType()}" styleClass="column grcnewUser" sortBy="#{l.activeARPU}">
						<h:outputLabel value="#{l.activeARPU}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(2)}-用户次日留存率" styleClass="column grcloginNewUservalidatedRadio" sortBy="#{l.the2LeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the2LeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(3)}-用户3日留存率" styleClass="column grcloginNewUservalidatedRadio" sortBy="#{l.the3LeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the3LeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(7)}-用户7日留存率" styleClass="column grcloginNewUservalidatedRadio" sortBy="#{l.the7LeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the7LeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(2)}-新增设备次日留存率" styleClass="column grcloginNewMacvalidatedRadio" sortBy="#{l.the2MacLeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the2MacLeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(3)}-新增设备3日留存率" styleClass="column grcloginNewMacvalidatedRadio" sortBy="#{l.the3MacLeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the3MacLeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(7)}-新增设备7日留存率" styleClass="column grcloginNewMacvalidatedRadio" sortBy="#{l.the7MacLeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the7MacLeftRadio)}" />
					</p:column>
					
					<p:columnGroup type="footer">
	            		<p:row>
		               		<p:column footerText="全部平台" styleClass="column grcnewUser"/>
                            <p:column footerText="#{bean.allPlatformData.activate}" styleClass="column grcnewUser"/>
                            <p:column footerText="#{bean.allPlatformData.newDevice}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{bean.allPlatformData.newUser}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{bean.allPlatformData.activeUser}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{bean.allPlatformData.payUser}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{bean.allPlatformData.pay}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.payUserInActiveRadio)}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{bean.allPlatformData.payARPU}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{bean.allPlatformData.activeARPU}" styleClass="column grcnewUser"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.the2LeftRadio)}" styleClass="column grcloginNewUservalidatedRadio"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.the3LeftRadio)}" styleClass="column grcloginNewUservalidatedRadio"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.the7LeftRadio)}" styleClass="column grcloginNewUservalidatedRadio"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.the2MacLeftRadio)}" styleClass="column grcloginNewMacvalidatedRadio"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.the3MacLeftRadio)}" styleClass="column grcloginNewMacvalidatedRadio"/>
		               		<p:column footerText="#{pageHelper.double2Percent(bean.allPlatformData.the7MacLeftRadio)}" styleClass="column grcloginNewMacvalidatedRadio"/>
	            		</p:row>
        			</p:columnGroup>
				</p:dataTable>
			</p:panel>
			
			<br />
			<p:separator />
			<p:panel id="panel1" header="分渠道数据" style="margin-bottom:10px;">
				<p:selectOneButton value="#{bean.selectedPlatform}">
		            <f:selectItem itemLabel="全部平台" itemValue="all" />
	            	<f:selectItem itemLabel="ios" itemValue="2" />
	            	<f:selectItem itemLabel="ios越狱" itemValue="1" />
	            	<f:selectItem itemLabel="安卓" itemValue="3" />
	            	<p:ajax update="dlist1 panel2" listener="#{bean.selectPlatform}" />
	        	</p:selectOneButton>
			
				<p:dataTable id="dlist1" var="l" value="#{bean.channelDatas}" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="15,30" rows="30" style="text-align:center;">
					<p:column headerText="渠道名称" styleClass="column grcnewUser" sortBy="#{pageHelper.getChannelNameById(l.channelid)}">
						<h:outputLabel value="#{pageHelper.getChannelNameById(l.channelid)}" />
					</p:column>
                    <p:column headerText="激活设备" styleClass="column grcnewUser" sortBy="#{l.activate}">
                        <h:outputLabel value="#{l.activate}" />
                    </p:column>
                    <p:column headerText="新增设备" styleClass="column grcnewUser" sortBy="#{l.newDevice}">
                        <h:outputLabel value="#{l.newDevice}" />
                    </p:column>
                    <p:column headerText="新增激活转化率" styleClass="column grcnewUser" sortBy="#{l.newActRate}">
                        <h:outputLabel value="#{pageHelper.double2Percent(l.newActRate)}" />
                    </p:column>
					<p:column headerText="新增帐号" styleClass="column grcnewUser" sortBy="#{l.newUser}">
						<h:outputLabel value="#{l.newUser}" />
					</p:column>
					<p:column headerText="活跃帐号" styleClass="column grcnewUser" sortBy="#{l.activeUser}">
						<h:outputLabel value="#{l.activeUser}" />
					</p:column>
					<p:column headerText="付费帐号" styleClass="column grcnewUser" sortBy="#{l.payUser}">
						<h:outputLabel value="#{l.payUser}" />
					</p:column>
					<p:column headerText="付费金额#{pageHelper.getMoneyType()}" styleClass="column grcnewUser" sortBy="#{l.pay}">
						<h:outputLabel value="#{l.pay}" />
					</p:column>
					<p:column headerText="活跃付费率" styleClass="column grcnewUser" sortBy="#{l.payUserInActiveRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.payUserInActiveRadio)}" />
					</p:column>
					<p:column headerText="付费ARPU#{pageHelper.getMoneyType()}" styleClass="column grcnewUser" sortBy="#{l.payARPU}">
						<h:outputLabel value="#{l.payARPU}" />
					</p:column>
					<p:column headerText="活跃ARPU#{pageHelper.getMoneyType()}" styleClass="column grcnewUser" sortBy="#{l.activeARPU}">
						<h:outputLabel value="#{l.activeARPU}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(2)}-用户次日留存率" styleClass="column grcloginNewUservalidatedRadio" sortBy="#{l.the2LeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the2LeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(3)}-用户3日留存率" styleClass="column grcloginNewUservalidatedRadio" sortBy="#{l.the3LeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the3LeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(7)}-用户7日留存率" styleClass="column grcloginNewUservalidatedRadio" sortBy="#{l.the7LeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the7LeftRadio)}" />
					</p:column>
					
					<p:column headerText="#{bean.getLeftDate(2)}-新增设备次日留存率" styleClass="column grcloginNewMacvalidatedRadio" sortBy="#{l.the2MacLeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the2MacLeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(3)}-新增设备3日留存率" styleClass="column grcloginNewMacvalidatedRadio" sortBy="#{l.the3MacLeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the3MacLeftRadio)}" />
					</p:column>
					<p:column headerText="#{bean.getLeftDate(7)}-新增设备7日留存率" styleClass="column grcloginNewMacvalidatedRadio" sortBy="#{l.the7MacLeftRadio}">
						<h:outputLabel value="#{pageHelper.double2Percent(l.the7MacLeftRadio)}" />
					</p:column>
				</p:dataTable>
			</p:panel>
			
			<p:panel id="panel2" header="渠道分小时数据" style="margin-bottom:10px;">
				<p:dataGrid id="chart2" var="c" value="#{bean}" columns="1" layout="grid">
					<p:selectOneMenu value="#{bean.selectZhiBiaoItem}">
			            <f:selectItems value="#{bean.allZhiBiaoItmes}" />
			            <p:ajax update="chart2" listener="#{bean.handleZhiBiaoChange}" />
		          	</p:selectOneMenu>
		        	
			       <p:dataTable id="dlist2" var="l" value="#{bean.channelHourDatas}" rowIndexVar="rowindex" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="15,30" rows="30" style="text-align:center;">
						<f:facet name="header">
					        #{bean.getFacetHeader()}
					    </f:facet>
						
						<p:column headerText="渠道名称" styleClass="column grcnewUser">
							<h:outputLabel value="#{pageHelper.getChannelNameById(l.channelid)}" />
						</p:column>
						
					    <p:columns value="#{bean.getColumnNames(rowindex)}" var="d" columnIndexVar="i" style="text-align:center;" rendered="#{bean.hourDatas.size() > 0}">
							<f:facet name="header">
      							<h:outputText value="#{bean.getHourStr(d)}" />
    						</f:facet>
							<h:outputLabel value="#{bean.getColumnValue(rowindex, i)}" />
						</p:columns>
					</p:dataTable>
			    </p:dataGrid>
			</p:panel>

            <p:separator />
            <p:panel id="panel4" header="分渠道实时在线" style="margin-bottom:10px;" >
                <p:remoteCommand name="executeOnOnhide" update="chart21" action="#{bean.handleChannelsChange}"/>

                <p:selectCheckboxMenu id="channelOnline" value="#{bean.selectedChannels}" label="渠道" filter="true" filterMatchMode="contains" panelStyle="width:160px" onHide="executeOnOnhide();">
                    <f:selectItems value="#{bean.channelItmes}" />
                </p:selectCheckboxMenu>
                <p:dataGrid id="chart21" var="c" value="#{bean.channelOnlineRealTimeChart}" columns="1" layout="grid">
                    <p:panel style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <div id="highchartChart21" style="width:100%;height:400px; border:0;">
                                <script type="text/javascript">
                                    generateChart('#{c.jsonStr}', 'linemore', '21', 'basewidth');
                                </script>
                            </div>
                        </h:panelGrid>
                    </p:panel>
                </p:dataGrid>
            </p:panel>
		</div>
	</h:form>

	<!-- 页脚 -->
	<div class="footer"></div>
</h:body>
</html>